﻿using Client.Framework.Message;
using Client.Framework.Socket;
using Client.Service;
using Client.ViewModel.MainViewModel;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Client
{
    /// <summary>
    /// LoginWindow.xaml 的交互逻辑
    /// </summary>
    public partial class LoginWindow : Window
    {
        public LoginWindow()
        {

            InitSocketClient();

            InitSysData();

            InitializeComponent();
            DataContext = new LoginViewModel(this);
        }


        /// <summary>
        /// 启动Socket客户端
        /// </summary>
        private void InitSocketClient()
        {
            MessageTypeManager.Init();
            ApplicationClient.Instance().InitClient();
        }

        /// <summary>
        /// 初始化系统数据
        /// </summary>
        private void InitSysData()
        {
            RoleService.Instance().InitRoles();
            OrgService.Instance().InitOrgTree();
        }


        protected override void OnClosing(CancelEventArgs e)
        {
            e.Cancel = true;
            this.Hide();
        }

    }
}
